var e, a = (e = require("@vant/weapp/toast/toast")) && e.__esModule ? e : {
    default: e
};

var t = require("../../utils/config"), o = require("../../utils/request"), c = require("../../utils/api"), s = require("../../utils/storage");

Page({
    data: {
        themeColor: getApp().globalData.themeColor,
        thumb: t.resourceRoot + "icon-report.png",
        checkCardList: [],
        checkedCheckCardList: [],
        showEmpty: !1,
        active: 0,
        account: "",
        password: "",
        companyCode: "",
        companyAccount: "",
        companyPassword: ""
    },
    onLoad: function(e) {
        var t = this;
        if (this.setData({
            checkCardList: [],
            active: e.active,
            companyCode: e.companyCode,
            companyAccount: e.companyAccount,
            companyPassword: e.companyPassword
        }), 1 == e.active) {
            var i = s.getStorageSync(s.storageKey.userBase);
            wx.showLoading({
                title: "正在加载中...",
                mask: !0
            }), o.request(o.HttpMethod.POST, c.apiRoute.selectCheckCardByCompany, {
                certificateNo: i.certificateNo,
                name: i.name,
                username: this.data.companyAccount,
                password: this.data.companyPassword,
                companyCode: this.data.companyCode
            }).then(function(e) {
                "20000" == e.code ? (t.setData({
                    checkCardList: e.data
                }), wx.hideLoading()) : ((0, a.default)({
                    message: e.message,
                    duration: 5e3
                }), wx.hideLoading());
            });
        }
    },
    onChange: function(e) {
        this.setData({
            checkedCheckCardList: e.detail
        });
    },
    addMyCheckCard: function() {
        this.data.checkCardList.length <= 0 ? (0, a.default)({
            message: "请选择需要添加的体检卡",
            duration: 5e3
        }) : o.request(o.HttpMethod.POST, c.apiRoute.bindCheckCardByCompany, {
            checkCardNoList: this.data.checkedCheckCardList
        }).then(function(e) {
            "20000" == e.code ? (wx.redirectTo({
                url: "/pages/my-link-check/my-link-check"
            }), wx.hideLoading()) : ((0, a.default)({
                message: e.message,
                duration: 5e3
            }), wx.hideLoading());
        });
    }
});